<template>
	<view>
		<view class="a1">
			<text>详细地址：</text>
			<input placeholder="请输入详细地址" v-model="address"/>
		</view>
		<u-line></u-line>
		<view class="a1">
			<text>标签：</text>
			<input placeholder="请输入标签" v-model="label"/>
		</view>
		<u-line></u-line>
		<view class="a1">
			<text>姓名：</text>
			<input placeholder="请输入姓名" v-model="name"/>
		</view>
		<u-line></u-line>
		<view class="a1">
			<text>电话号码：</text>
			<input placeholder="请输入电话号码" v-model="phone"/>
		</view>
		<u-line></u-line>
		<u-button type="primary" text="保存" @click="tosave"></u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				address:'',
				label:'',
				name:'',
				phone:''
			}
		},
		methods: {
			tosave(){
				if(this.name===''||this.label===''||this.phone===''||this.address===''){
					uni.showToast({
						title:'参数错误',
						icon:'error'
					})
					return
				}
				const data={
					addressDetail:this.address,
					name:this.name,
					phone:this.phone,
					label:this.label
				}
				this.api.get('/prod-api/api/takeout/address','POST',data).then(res=>{
					if(res.data.code===200){
						setTimeout(function(){
							uni.showToast({
								title:'添加成功'
							})
						},700)
						uni.redirectTo({
							url:'/pages/other/takaway/address/address'
						})
					}else{
						console.log(res.data)
					}
				})
			}
		}
	}
</script>

<style lang="scss">
.a1{
	display: flex;
	margin-top: 20px;
	margin-bottom: 20px;
}
</style>
